﻿Namespace GameMenu

    Module mGameMenu

        Private mVisible As Boolean

        Private WithEvents GameMenu As GUI.MirWindow

        Private WithEvents btnSettings As GUI.MirButton
        Private WithEvents btnChatSettings As GUI.MirButton
        Private WithEvents btnMessageSettings As GUI.MirButton
        Private WithEvents btnGroup As GUI.MirButton
        Private WithEvents btnGuild As GUI.MirButton
        Private WithEvents btnAvatar As GUI.MirButton
        Private WithEvents btnSiege As GUI.MirButton
        Private WithEvents btnExit As GUI.MirButton
        Private WithEvents btnAutoPot As GUI.MirButton

        Private WithEvents HideMenu As GUI.MirButton
        'Dim WithEvents btnFilterWhisper As GUI.MirButton
        'Dim WithEvents btnFilterGroup As GUI.MirButton
        'Dim WithEvents btnFilterGuild As GUI.MirButton
        'Dim WithEvents btnFilterSystem As GUI.MirButton

        Private WithEvents ExitWin As GUI.MirWindow

        Public WithEvents btnLogout As GUI.MirButton
        Public WithEvents btnDoShutdown As GUI.MirButton

        Public WithEvents HideExit As GUI.MirButton

        Public Sub Init()

            mVisible = False
            GameMenu = New GUI.MirWindow("GameMenu", Constants.gGameResX - 136, Constants.gGameResY - 391, 136, 391)

            HideMenu = New GUI.MirButton(GameMenu, "HideMenu", 106, 357, 0.0F, ImgLibs.GameInter, 0, 3036, 3036)
            
            btnSettings = New GUI.MirButton(GameMenu, "btnSettings", 25, 32, 0.0F, ImgLibs.GameInter, 0, 312, 312, "General Settings", , "Settings", , 88)
            btnChatSettings = New GUI.MirButton(GameMenu, "btnChatSettings", 25, 67, 0.0F, ImgLibs.GameInter, 0, 312, 312, "Chat Settings", , "Chat", , 88)
            btnMessageSettings = New GUI.MirButton(GameMenu, "btnMessageSettings", 25, 102, 0.0F, ImgLibs.GameInter, 0, 312, 312, "MessageSettings", , "Message", , 88)
            btnGroup = New GUI.MirButton(GameMenu, "btnGroup", 25, 137, 0.0F, ImgLibs.GameInter, 0, 312, 312, "Group Window", , "Group", , 88)
            btnGuild = New GUI.MirButton(GameMenu, "btnGuild", 25, 172, 0.0F, ImgLibs.GameInter, 0, 312, 312, "Guild Window", , "Guild", , 88)
            btnAvatar = New GUI.MirButton(GameMenu, "btnAvatar", 25, 207, 0.0F, ImgLibs.GameInter, 0, 312, 312, "Upload Avatar", , "Avatar", , 88)
            btnSiege = New GUI.MirButton(GameMenu, "btnSiege", 25, 242, 0.0F, ImgLibs.GameInter, 0, 312, 312, "Siege Interface", , "Siege", , 88)
            btnExit = New GUI.MirButton(GameMenu, "btnExit", 25, 277, 0.0F, ImgLibs.GameInter, 0, 312, 312, "Exit Game", , "Exit", , 88)
            btnAutoPot = New GUI.MirButton(GameMenu, "btnAutopot", 25, 312, 0.0F, ImgLibs.GameInter, 0, 312, 312, "AutoPot Functions", , "Auto-Pot", , 88)

            With Libs.GameInter.Image(411)

                ExitWin = New GUI.MirWindow("ExitWin", (Constants.gGameResX / 2) - (.Header.Width / 2), (Constants.gGameResY / 2) - (.Header.Height / 2), .Header.Width, .Header.Height)

                btnLogout = New GUI.MirButton(ExitWin, "btnLogout", 116, 75, 0.0F, ImgLibs.GameInter, 0, 412, 412, "Logout of game", , "Logout", , 69)
                btnDoShutdown = New GUI.MirButton(ExitWin, "btnDoShutdown", 26, 75, 0.0F, ImgLibs.GameInter, 0, 412, 412, "Exit game", , "Exit", , 69)

                HideExit = New GUI.MirButton(ExitWin, "HideExit", 207, 72, 0.0F, ImgLibs.GameInter, 0, 3036, 3036)

            End With

        End Sub

        Public Sub Shutdown()

            GameMenu.Destory()
            ExitWin.Destory()

        End Sub

        Private Sub ChatBox_DrawWindow(ByRef mode As Globals.DrawingMode, ByRef x As Integer, ByRef y As Integer, ByRef z As Single) Handles GameMenu.DrawWindow

            If mode = Globals.DrawingMode.Normal Then

                With Libs.GameInter.Image(311)

                    .Draw(x - 58, y - 60, z)

                End With

            End If

        End Sub

        Public Sub ToggleShowMenu()

            If mVisible Then
                Windows.RemoveWindow(GameMenu)
                mVisible = False
            Else
                Windows.AddWindow(GameMenu, Windows.WindowType.Normal)
                mVisible = True
            End If

        End Sub

        Private Sub HideMenu_Click() Handles HideMenu.Click
            ToggleShowMenu()
        End Sub

        Private Sub btnExit_Click() Handles btnExit.Click
            ShowExit()
        End Sub

        Public Sub ShowExit()

            Windows.AddWindow(ExitWin, Windows.WindowType.AlwaysOnTop)

        End Sub

        Public Sub HideExitWin()

            Windows.RemoveWindow(ExitWin)

        End Sub

        Private Sub ExitWin_DrawWindow(ByRef mode As Globals.DrawingMode, ByRef x As Integer, ByRef y As Integer, ByRef z As Single) Handles ExitWin.DrawWindow

            If mode = Globals.DrawingMode.Normal Then

                With Libs.GameInter.Image(411)
                    .Draw(x, y, z)
                End With

            ElseIf mode = Globals.DrawingMode.Text Then

                DirectX.ProFont9.DrawNormalText("Are you sure you want to exit?", x + 30, y + 40, Color.White, z)

            End If

        End Sub

        Private Sub btnCancelExit_Click() Handles btnLogout.Click
            SelectChar.Logout()
        End Sub

        Private Sub btnDoShutdown_Click() Handles btnDoShutdown.Click
            Globals.bEnding = True
        End Sub

        Private Sub btnAutoPot_RequestingTooltip(tttxt As String) Handles btnAutoPot.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnAvatar_RequestingTooltip(tttxt As String) Handles btnAvatar.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnChatSettings_RequestingTooltip(tttxt As String) Handles btnChatSettings.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnDoShutdown_RequestingTooltip(tttxt As String) Handles btnDoShutdown.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnExit_RequestingTooltip(tttxt As String) Handles btnExit.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnGroup_Click() Handles btnGroup.Click
            GroupWindow.Show()
        End Sub

        Private Sub btnGroup_RequestingTooltip(tttxt As String) Handles btnGroup.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnGuild_RequestingTooltip(tttxt As String) Handles btnGuild.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnLogout_RequestingTooltip(tttxt As String) Handles btnLogout.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnMessageSettings_RequestingTooltip(tttxt As String) Handles btnMessageSettings.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnSettings_Click() Handles btnSettings.Click

        End Sub

        Private Sub btnSettings_RequestingTooltip(tttxt As String) Handles btnSettings.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub btnSiege_RequestingTooltip(tttxt As String) Handles btnSiege.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub HideExit_Click() Handles HideExit.Click
            HideExitWin()
        End Sub

        Private Sub HideExit_RequestingTooltip(tttxt As String) Handles HideExit.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Private Sub HideMenu_RequestingTooltip(tttxt As String) Handles HideMenu.RequestingTooltip
            GameWindow.SetTooltip(tttxt, 0, True)
        End Sub

        Public ReadOnly Property Visible() As Boolean
            Get
                Return mVisible
            End Get
        End Property

    End Module

End Namespace
